package com.rtzh.learnkotlin.uitls

import android.app.Activity

/**
 * activity栈管理
 */
object ActivityCollector {


    private val activitys = ArrayList<Activity>()


    fun addActivity(activity: Activity) {
        activitys.add(activity)
    }

    fun removeActivity(activity: Activity) {
        activitys.remove(activity)
    }

    fun finishAll() {
        for (activity in activitys){
            if (!activity.isFinishing){
                activity.finish()
            }
        }
        activitys.clear()
    }

}